<?php
/* Dependant on _Page */
class Navigation {
	
	function __construct(){
		
	}
	
	function draw(){
		$db = F::get()->DB();
		//Draw a top nav only
		$sql = "
		SELECT `keyword`, `title`, `url` FROM `Page` 
		WHERE `parent` = 0 
		AND `hidden` = 0";
		$res = $db->query( $sql );
		$num = $db->numRows( $res );
		
		echo('
			<div class="navbar navbar-fixed-top">
			<div class="navbar-inner">
			<div class="container-fluid">
			<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			</a>
			<a class="brand" href="#">Duncan Scholtz</a>
			');
		
		if( $num > 0 ){
			$keyword = F::get()->Controller()->getKeyword(); 
			echo('<ul class="nav">');
			while( $row = $db->fetchRow( $res ) ){
				$page = new _Page();
				$page->loadArray($row);
				echo('<li '.($keyword == $page->keyword ? 'class="active"' : '').'>');
				$page->drawNavLink();
				echo('<li>');
			}
			echo('</ul>');
		}
		
		
		echo('
			<div class="nav-collapse">
			<span class="pull-right">
			'.F::get()->Tpl()->drawLogin().'
			</span>
			</div><!--/.nav-collapse -->
			
			</div>
			</div>
			</div>');
	}
	
	
}
?>
